<?php
session_start();
if ($_SESSION["access"] != "granted")
{
   session_destroy();
   header("Location: ./index.php");
}
require_once('f.php');

$msg = '';
do
{
   $settings = loadSettings();

   // If one => all
   if (!isset($_POST['command']))
   {
      break;
   }

   unset($_POST['Save']);

   saveSettings($_POST);

   /// Reload settings
   $settings = loadSettings();

   $msg = 'Saved!';
   
} while(false);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="index,follow" name="robots" />
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
<link href="pics/homescreen.gif" rel="apple-touch-icon" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<title><?php echo getTitle()?></title>
</head>

<body>

<div id="topbar">
	<div id="title">
		<?php echo getTitle()?></div>
	<div id="leftbutton"> 
		<a href="index.php" class="noeffect">Logout</a> </div> 
</div>
<div id="tributton">
	<div class="links">
		<a href="main.php">Main</a><a href="status.php">Status</a><a id="pressed" href="settings.php">Settings</a></div>
</div>
<div id="content">	
   <?php if ($msg != ''):?>
	<ul class="pageitem">
		<li class="textbox"><span class="header">Yep!</span><?php echo $msg?></li>
	</ul>
   <?php endif;?>  
	<form method="post" action="settings.php">
		<span class="graytitle">Download Options</span>
		<ul class="pageitem">
			<li class="smallfield"><span class="name">Command:</span><input value="<?php echo $settings['command']?>" placeholder="wget" type="text" id="command" name="command" />
			</li>
			<li class="smallfield"><span class="name">Parameters:</span><input value="<?php echo $settings['parameters']?>" placeholder="--directory-prefix=" type="text" id="parameters" name="parameters" />
			</li>
         <li class="smallfield"><span class="name">Rec.ly parm:</span><input value="<?php echo $settings['recursion']?>" placeholder="-r" type="text" id="recursion" name="recursion" />
			</li>
		</ul>
		<span class="graytitle">Folder Options</span>
		<ul class="pageitem">
         <li class="smallfield"><span class="name">Main folder:</span><input value="<?php echo $settings['destination']?>" placeholder="/home/user/download" type="text" id="destination" name="destination" />
			</li>
         <li class="smallfield"><span class="name">Torrent folder:</span><input value="<?php echo $settings['torrent_folder']?>" placeholder="/home/user/torrent" type="text" id="torrent_folder" name="torrent_folder" />
			</li>
         <li class="smallfield"><span class="name">Dropbox folder:</span><input value="<?php echo $settings['dropbox_folder']?>" placeholder="/home/user/dropbox" 
type="text" id="dropbox_folder" name="dropbox_folder" />
			</li>
		</ul>		
      <ul class="pageitem">			
			<li class="button">
			<input name="Save" type="submit" value="Save" /></li>
		</ul>		
		</fieldset></form>
</div>
<div id="footer">
	<a href="http://iwebkit.net">Powered by iWebKit</a></div>

</body>

</html>
